<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body {
            color: #fff;
            background: purple;
            font-size: 18px;
        }

        .parent {
            position: relative;
            background: lightseagreen;
            width:500px; 
            height:500px;
        }
        .child {
            position: absolute;
            top: 50%;
            left: 50%;
            width: 280px;
            height: 280px;
            margin-left: -140px;
            margin-top: -140px;
            background: pink;
        }
    </style>
</head>

<body>
    <div class="parent">
        <div class="child">
            水平垂直居中水平垂直居中 水平垂直居中水平垂直居中
        </div>
    </div>
</body>

</html>